package fr.umlv.m2.uwp2011.persistence.matiere;

import java.io.Serializable;
import java.util.Iterator;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;


@SuppressWarnings("serial")
@Entity
@Table(name ="CURSUS")
public class Cursus implements Serializable {
	//private final static String columnType="INTEGER UNSIGNED";
	@Id
	@GeneratedValue
	@Column(name ="CURSUS_ID")
	private Long id;
	
	@Column(name="CURSUS_LIBELLE")
	private String libelle;

	@ManyToMany(cascade = CascadeType.REFRESH)
    @JoinTable(name="CURSUS_TRONC_COMMUN",
            joinColumns={@JoinColumn(name="CURSUS_ID", columnDefinition="INTEGER UNSIGNED", nullable=false)},
            inverseJoinColumns={@JoinColumn(name="TRONC_COMMUN_ID", columnDefinition="INTEGER UNSIGNED", nullable=false)})
	private List<TroncCommun> listTroncCommun;
	
	public String getLibelle() {
		return libelle;
	}

	public void setLibelle(String libelle) {
		this.libelle = libelle;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id=id;
	}
	public void setListTroncCommun(List<TroncCommun> listTroncCommun) {
		this.listTroncCommun = listTroncCommun;
	}

	public Iterator<TroncCommun> iteratorTroncCommun() {
		return listTroncCommun.iterator();
	}

}
